


'''发送请求和日志'''
import requests
from loguru import logger


class BaseApi:
    pingtai_BASE_URL = ''
    yonghu_BASE_URL = ''
    shanghu_BASE_URL = ''
    # def __init__(self):
    #     pass

    def pingtai_qingqiu(self,data:dict):
        if self.pingtai_BASE_URL != '':
            data['url'] = self.pingtai_BASE_URL + data['url']
        logger.info('接口请求数据为:{}'.format(data))
        r = requests.request(**data)
        logger.info('接口响应数据为:{}'.format(r.text))
        return r.json()

    def yonghu_qingqiu(self,data:dict):
        if self.yonghu_BASE_URL != '':
            data['url'] = self.yonghu_BASE_URL + data['url']
        logger.info('接口请求数据为:{}'.format(data))
        r = requests.request(**data)
        logger.info('接口响应数据为:{}'.format(r.text))
        return r.json()

    def shanghu_qingqiu(self,data:dict):
        if self.shanghu_BASE_URL != '':
            data['url'] = self.shanghu_BASE_URL + data['url']
        logger.info('接口请求数据为:{}'.format(data))
        r = requests.request(**data)
        logger.info('接口响应数据为:{}'.format(r.text))
        return r.json()


